package com.rao.springbootschoolshop.config.admin;


import com.rao.springbootschoolshop.interceptor.admin.AuthorityInterceptor;
import com.rao.springbootschoolshop.interceptor.admin.AdminLoginInterceptor;
import com.rao.springbootschoolshop.constant.RunTimeConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 * 注册配置拦截器的配置文件
 */
@Configuration
public class AdminWebConfig implements WebMvcConfigurer{

    @Autowired
    private AdminLoginInterceptor adminLoginInterceptor; //我们自定义的拦截器
    @Autowired
    private AuthorityInterceptor authorityInterceptor; //权限拦截器

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //将loginInterceptor拦截器配置到项目启动文件中
        registry.addInterceptor(adminLoginInterceptor).addPathPatterns("/**").excludePathPatterns(RunTimeConstant.LoginExcludePathPatterns);
        registry.addInterceptor(authorityInterceptor).addPathPatterns("/**").excludePathPatterns(RunTimeConstant.AuthorityExcludePathPatterns);
    }
    }
